package indi.h.security.encryption.msgex;

import java.math.BigInteger;
import java.security.MessageDigest;

import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;

import org.apache.commons.codec.digest.DigestUtils;

public class Test {
	public static void main(String[] args) throws Exception {
		MessageDigest md5Digest = DigestUtils.getMd5Digest();
		
		System.out.println(new BigInteger(md5Digest.digest("sb".getBytes())).toString(16));
		
		MessageDigest sha256Digest = DigestUtils.getSha256Digest();
		System.out.println(new BigInteger(sha256Digest.digest("sb".getBytes())).toString(16));
		
		KeyGenerator instance = KeyGenerator.getInstance("HmacSHA1");
		SecretKey generateKey = instance.generateKey();
		Mac instance2 = Mac.getInstance("HmacSHA1");
		instance2.init(generateKey);
		byte[] doFinal = instance2.doFinal("sb".getBytes());
		System.out.println(new BigInteger(doFinal).toString(16));
		
	}
}
